package day11;
import java.io.*;
public class learn6 {
    public static void main(String[] args) throws IOException {
        //创建文件
        File file=new File("D:\\WUDownloadCache\\tets2.txt");
        file.createNewFile();
        String str1="java开发";
        /*byte [] words=str1.getBytes();
        //写入流
        /*FileOutputStream fileOutputStream=new FileOutputStream(file);
        fileOutputStream.write(words);
        System.out.println("文件不存在");
        fileOutputStream.close();*/

        //通过写入流来添加数据
        String str="好好学习Java";
        byte[] words=str.getBytes();
        FileOutputStream fileOutputStream=new FileOutputStream(file);
        fileOutputStream.write(words);
        System.out.println("打开文件已经存在");
        fileOutputStream.close();
    }
}
